<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<!--{hook admin_user_update_start.htm}-->

<div class="row">
	<div class="col-lg-8 offset-lg-2">
		<div class="btn-group m-b-1" role="group">
			<?php echo admin_tab_active($menu['user']['tab'], 'list');?>
		</div>
		<div class="card">
			<div class="card-block">
				<h4 class="card-title">编辑用户</h4>
				<form action="<?php echo url("user-update-$_uid");?>" method="post" id="form">
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">邮箱：</label>
						<div class="col-sm-10">
							<input type="text" id="email" name="email" class="form-control" value="<?php echo $_user['email'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">用户名：</label>
						<div class="col-sm-10">
							<input type="text" id="username" name="username" class="form-control" value="<?php echo $_user['username'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">登陆密码：</label>
						<div class="col-sm-10">
							<input type="text" id="password" name="password" class="form-control" placeholder="不修改请留空">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">提款密码：</label>
						<div class="col-sm-10">
							<input type="text" id="password_ti" name="password_ti" class="form-control" placeholder="不修改请留空">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">用户组：</label>
						<div class="col-sm-10">
							<select id="group" name="group" class="form-control">
								<option value="0">商户</option>
								<option value="1" <?php if($_user['is_proxy']==1){echo 'selected';} ?>>代理</option>
								<option value="2" <?php if($_user['is_admin']==1){echo 'selected';} ?>>管理员</option>
								<option value="3" <?php if($_user['is_open']==0){echo 'selected';} ?>>待审核</option>
							</select>
						</div>
					</div>
				<?php if(!empty($daili)){?>
				<div class="form-group row">
					<label class="col-sm-2 form-control-label">所属代理：</label>
					<div class="col-sm-10">
						<select id="parent" name="parent" class="form-control">
								<option value="0">请选择</option>
								<?php foreach($daili as $v){?>
									<option value="<?php echo $v['uid']?>" ><?php echo $v['username']?></option>
								<?php }?>
						</select>
					</div>
				</div>
				<?php }?>
					<?php foreach($bank as $b){ ?>
					<hr>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">银行卡号：<br><span style="font-size:12px;color:#666;">(若要删除请将此行留空)</span></label>
						<div class="col-sm-10">
							<input type="text" id="bankcode" name="bankcode[<?php echo $b['id'];?>]" class="form-control" value="<?php echo $b['code'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">银行名称：</label>
						<div class="col-sm-10">
							<input type="text" id="bankname" name="bankname[<?php echo $b['id'];?>]" class="form-control" value="<?php echo $b['bank'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">持卡人：</label>
						<div class="col-sm-10">
							<input type="text" id="bankhost" name="bankhost[<?php echo $b['id'];?>]" class="form-control" value="<?php echo $b['name'];?>">
						</div>
					</div>
					<hr>
					<?php } ?>

					<div class="form-group row">
						<label class="col-sm-2 form-control-label">真实姓名：</label>
						<div class="col-sm-10">
							<input type="text" id="name" name="name" class="form-control" value="<?php echo $_user['info_name'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">身份证号：</label>
						<div class="col-sm-10">
							<input type="text" id="id" name="id" class="form-control" value="<?php echo $_user['info_id'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">手机号：</label>
						<div class="col-sm-10">
							<input type="text" id="mobile" name="mobile" class="form-control" value="<?php echo $_user['info_mobile'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">QQ号：</label>
						<div class="col-sm-10">
							<input type="text" id="qq" name="qq" class="form-control" value="<?php echo $_user['info_qq'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">网站名称：</label>
						<div class="col-sm-10">
							<input type="text" id="sitename" name="sitename" class="form-control" value="<?php echo $_user['info_sitename'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">网站地址：</label>
						<div class="col-sm-10">
							<input type="text" id="sitelink" name="sitelink" class="form-control" value="<?php echo $_user['info_sitelink'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">IP白名单：</label>
						<div class="col-sm-10">
							<input type="text" id="allow_ips" name="allow_ips" class="form-control" value="<?php echo $_user['allow_ips'];?>" placeholder="多个地址用,号分隔 留空为不限制">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">银行开关：</label>
						<div class="col-sm-10">
							<select id="bank_open" name="bank_open" class="form-control">
								<option value="1" <?php if($_user['bank_open']==1){echo 'selected';} ?>>开</option>
								<option value="0" <?php if($_user['bank_open']==0){echo 'selected';} ?>>关</option>
							</select>
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">注册时间：</label>
						<div class="col-sm-10"><?php echo date('Y-m-d H:i:s',$_user['create_time']);?></div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">登录时间：</label>
						<div class="col-sm-10"><?php echo date('Y-m-d H:i:s',$_user['login_time']);?></div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">注册IP：</label>
						<div class="col-sm-10"><?php echo $_user['create_ip'];?></div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">登录IP：</label>
						<div class="col-sm-10"><?php echo $_user['login_ip'];?></div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label"></label>
						<div class="col-sm-10">
							<button type="submit" class="btn btn-primary btn-block" id="submit" data-loading-text="提交中...">确认</button>
							<a role="button" class="btn btn-secondary btn-block m-t-1" href="javascript:history.back();">返回</a>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<!--{hook admin_user_update_end.htm}-->

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>


<script>
var jform = $('#form');
var jsubmit = $('#submit');
jform.on('submit', function() {
	jform.reset();
	jsubmit.button('loading');
	var postdata = jform.serialize();
	$.xpost(jform.attr('action'), postdata, function(code, message) {
		if(code == 0) {
			$.alert(message);
			jsubmit.text(message).delay(3000).button('reset');
		} else if(code < 0) {
			$.alert(message);
			jsubmit.button('reset');
		} else {
			alert(message);
			jform.find('[name="'+code+'"]').alert(message).focus();
			jsubmit.button('reset');
		}
	});
	return false;
});

$('#nav_pc li.user, #nav_mobile li.user').tab('show');

</script>